<template>
	<view class="flex flex-direction bg-white" style="width: 100vw; height: 100vh;">
		<cu-custom :isBack="true">
			<block slot="content">
				<text style="font-size: 32rpx;">支付结果页</text>
			</block>
		</cu-custom>
		<view class="flex-sub flex flex-direction justify-between align-center bg-white" style="padding: 0 32rpx;">
			<view class="flex flex-direction" style="width: 100%;">
				<view class="flex flex-direction align-center">
					<view style="width: 150rpx;height: 150rpx;background-color: #007AFF;margin-top: 80rpx"></view>
					<text style="font-size: 48rpx;font-weight: bold;color: #007AFF;line-height: 64px; margin-top: 20rpx;">
						{{data.message}}
					</text>
				</view>
				<view v-if="data.success" style="font-size: 32rpx;color: #666666;line-height: 50rpx;margin-top: 50rpx;padding: 20rpx 0;">
					<view>商品名称：{{data.result.contentTitle}}</view>
					<view>实付金额：¥{{data.result.totalFee}}</view>
					<view>商品订单：{{data.result.orderNo}}</view>
					<view>支付方式：{{data.result.payType == 1 ? "微信":"支付宝"}}</view>
				</view>
			</view>
			<view v-if="data.success" @click="returnPage()" class="flex justify-center align-center confirm-button">
				去学习
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				data: this.$Route.query.data?this.$Route.query.data:{success: true, message:"支付成功", result:{contentTitle:'季度会员', totalFee: 5000, orderNo:'20210707222741469'}, payType:1},
			}
		},
		onLoad() {
			// console.log(this.$store.getters.pagePrevious);
			if(!this.data.success) {
				setTimeout(function() {
					uni.navigateBack({
						delta: 1
					});
				}, 3000);
			}
		},
		methods: {
			returnPage() {
				// console.log("test")
				let pagePrevious = this.$store.getters.pagePrevious;
				// console.log("page", page)
				if(pagePrevious) {
					// console.log("page", this.$store.getters.pagePrevious)
					// console.log("router", this.$Router)
					const page = JSON.parse(pagePrevious);
					this.$Router.push(page);
				} else {
					this.$Router.push({name:'indexFrontEnd'});
				}
			}
		}
	}
</script>

<style>
	.confirm-button {
		width: 660rpx;
		height: 100rpx;
		margin-bottom: 10rpx;
		background: #007AFF;
		border-radius: 8rpx;
		font-size: 32rpx;
		font-weight: bold;
		color: #FFFFFF;
		line-height: 44rpx;
	}
</style>
